<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
const isMac = navigator.platform.indexOf('Mac') === 0;
const kBehaviors = window.internals ? ['mac', 'win'] : isMac ? ['mac'] : ['win'];
for (const behavior of kBehaviors) {
  if (window.internals) {
    internals.settings.setEditingBehavior(behavior);
    internals.settings.setSelectTrailingWhitespaceEnabled(behavior !== 'mac');
  }

selection_test(
  '<div contenteditable dir="rtl">|\nabc \u05D0\u05D1\u05D2 xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\n|abc \u05D0\u05D1\u05D2 xyz\n</div>',
  `${behavior} 10-0 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\n|abc \u05D0\u05D1\u05D2 xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\n|abc \u05D0\u05D1\u05D2 xyz\n</div>',
  `${behavior} 10-1 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\na|bc \u05D0\u05D1\u05D2 xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\n|a^bc \u05D0\u05D1\u05D2 xyz\n</div>',
  `${behavior} 10-2 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nab|c \u05D0\u05D1\u05D2 xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\n|ab^c \u05D0\u05D1\u05D2 xyz\n</div>',
  `${behavior} 10-3 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nabc| \u05D0\u05D1\u05D2 xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\n|abc^ \u05D0\u05D1\u05D2 xyz\n</div>',
  `${behavior} 10-4 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nabc |\u05D0\u05D1\u05D2 xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\n|abc ^\u05D0\u05D1\u05D2 xyz\n</div>',
  `${behavior} 10-5 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nabc \u05D0|\u05D1\u05D2 xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\nabc |\u05D0^\u05D1\u05D2 xyz\n</div>',
  `${behavior} 10-6 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nabc \u05D0\u05D1|\u05D2 xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\nabc |\u05D0\u05D1^\u05D2 xyz\n</div>',
  `${behavior} 10-7 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nabc \u05D0\u05D1\u05D2| xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\nabc |\u05D0\u05D1\u05D2^ xyz\n</div>',
  `${behavior} 10-8 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nabc \u05D0\u05D1\u05D2 |xyz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\nabc |\u05D0\u05D1\u05D2 ^xyz\n</div>',
  `${behavior} 10-9 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nabc \u05D0\u05D1\u05D2 x|yz\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\nabc \u05D0\u05D1\u05D2 |x^yz\n</div>',
  `${behavior} 10-10 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nabc \u05D0\u05D1\u05D2 xy|z\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\nabc \u05D0\u05D1\u05D2 |xy^z\n</div>',
  `${behavior} 10-11 rtl right word`);

selection_test(
  '<div contenteditable dir="rtl">\nabc \u05D0\u05D1\u05D2 xyz|\n</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="rtl">\nabc \u05D0\u05D1\u05D2 |xyz^\n</div>',
  `${behavior} 10-12 rtl right word`);
}
</script>
